package com.ym.b2b.salesman.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ym.b2b.commons.controller.BaseController;
import com.ym.b2b.salesman.service.EmBSalesmanBuyerService;
import com.ym.b2b.salesman.sqlbean.EmBSalesmanBuyer;
import com.ym.b2b.user.service.EmCUserService;
import com.zc.commons.base.Page;
import com.zc.commons.base.Result;

/**
 * @ClassName: EmCProviderController
 * @Description: TODO
 * @Author tangxj
 * @Date 2015-1-15 上午11:21:47
 * @Modify
 * @CopyRight B2B小组
 */
@Controller
@RequestMapping("/embsalesmanbuyer")
public class EmBSalesmanBuyerController extends BaseController {

    @Autowired
    private EmBSalesmanBuyerService emBSalesmanBuyerService;
    @Autowired
    private EmCUserService          emCUserService;

    @RequestMapping("searchPageSalesmanBuyer.do")
    @ResponseBody
    public Result searchPageSalesmanBuyer(EmBSalesmanBuyer emBSalesmanBuyer, Page<EmBSalesmanBuyer> page,
                                          HttpServletRequest req) {

        Result result = new Result();
        try {
            result = emBSalesmanBuyerService.searchPageEmBSalesmanBuyer(page, emBSalesmanBuyer);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;

    }

    @RequestMapping(value = "insertSalesmanBuyer.do")
    @ResponseBody
    public Result insertSalesmanBuyer(EmBSalesmanBuyer emBSalesmanBuyer, HttpServletRequest req) {
        Result result = new Result();
        try {
            result = emBSalesmanBuyerService.insertEmBSalesmanBuyer(emBSalesmanBuyer);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;
    }

    // 删除一条记录
    @RequestMapping("deleteSalesmanBuyer.do")
    @ResponseBody
    public Result deleteSalesmanBuyer(EmBSalesmanBuyer emBSalesmanBuyer, HttpServletRequest req) {
        Result result = new Result();
        try {
            result = emBSalesmanBuyerService.deleteEmBSalesmanBuyer(emBSalesmanBuyer);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;
    }

    // 删除多条记录内容
    @RequestMapping("deleteMultipleEmBSalesmanBuyers.do")
    @ResponseBody
    public Result deleteMultipleEmBSalesmanBuyers(String belongIdList, HttpServletRequest req) {
        Result result = new Result();
        try {
            result = emBSalesmanBuyerService.deleteMultipleEmBSalesmanBuyers(belongIdList);
        } catch (Exception e) {
            result.setCodeResult(Result.CODE_100, e.getMessage());
        }
        return result;
    }

}
